package com.it.executorService;

import java.util.concurrent.*;

/**
 * ClassName: ExecutorServiceDemo1
 * Description: 线程池创建Runnable任务
 *
 * @Author: csx
 * @Create: 2025/5/8 - 8:53
 * @version: v1.0
 */
public class ExecutorServiceDemo1 {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(3, 5,
                10, TimeUnit.SECONDS, new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

        Runnable r1 = () -> {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + " 输出：" + i);
            }
        };
        pool.execute(r1);
        pool.execute(r1);
        pool.execute(r1);

//        pool.shutdown();
    }
}





























